var FU = {};
(function (exports) {

    var id = BaseUtil.getParameter("id");

    var Urls = {
        getDataUrl : "/sys/sysUser/info",
        createDataUrl : "/sys/sysUser/create",
        updateDataUrl : "/sys/sysUser/update"
    }

    function loadUserData(id) {
        BaseUtil.doPost(Urls.getDataUrl, {id, id}, function (msg, result) {
            EasyUiUtil.setFormData("#user-data-form", result);
            return false;
        })
    }


    /**
     * 保存数据
     */
    function saveData() {
        var form = $("#user-data-form");
        var flag = EasyUiUtil.validateForm(form);
        if(!flag) {
            return false;
        }
        var data = EasyUiUtil.getFormData(form)
        var url = BaseUtil.checkValue(data["userId"]) ? Urls.updateDataUrl: Urls.createDataUrl;
        BaseUtil.doPost(url, data, function (msg, result) {
            EasyUiUtil.closeCurrentDialog(result);
        });
    }

    /**
     * 关闭
     */
    function closeDialog() {
        EasyUiUtil.closeCurrentDialog();
    }

    exports.saveData=saveData;
    exports.closeDialog=closeDialog;
    exports.loadUserData = loadUserData;

    $(function () {
        if(BaseUtil.checkValue(id)) {
            FU.loadUserData(id);
        }
    })
})(FU);